package devcken.lang;

public class NumberParser
{
	public static Integer parseToInt(String target, Integer defaultValue)
	{
		try
		{
			return Integer.parseInt(target);
		}
		catch (NumberFormatException error)
		{
			return defaultValue;
		}
	}
	
	public static Long parseToLong(String target, Long defaultValue)
	{
		try
		{
			return Long.parseLong(target);
		}
		catch (NumberFormatException error)
		{
			return defaultValue;
		}
	}
	
	public static Float parseToFloat(String target, Float defaultValue)
	{
		try
		{
			return Float.parseFloat(target);
		}
		catch (NumberFormatException | NullPointerException error)
		{
			return defaultValue;
		}
	}
	
	public static Double parseToDouble(String target, Double defaultValue)
	{
		try
		{
			return Double.parseDouble(target);
		}
		catch (NumberFormatException error)
		{
			return defaultValue;
		}
	}
}